#include "SeparatorDelegate.h"

#ifdef __QT5_TARGET

#include <QtCore/QPoint>
#include <QtCore/QDate>
#include <QtGui/QColor>
#include <QtGui/QPainter>
#include <QtGui/QPen>

#else

#include <QColor>
#include <QDate>
#include <QPoint>
#include <QPen>

#endif

SeparatorDelegate::SeparatorDelegate(QObject* parent):QStyledItemDelegate(parent)
{
}

SeparatorDelegate::~SeparatorDelegate(void)
{
}

void SeparatorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	
	QStyledItemDelegate::paint(painter,option,index);
	QPen pen;
	pen.setColor(Qt::blue);
	pen.setWidth(2);
	painter->setPen(pen);
	QPoint* point = new QPoint[4];

	point[0] = option.rect.bottomLeft();
	point[1] = option.rect.bottomRight();
	painter->drawLines(point,1);

	if((QDate::currentDate().dayOfWeek() +2) % 7 == index.column() +1)
	{
		point[0] = option.rect.topLeft();
		point[1] = option.rect.bottomLeft();
		point[2] = option.rect.topRight();
		point[3] = option.rect.bottomRight();
		pen.setColor(Qt::red);
		painter->setPen(pen);
		painter->drawLines(point,2);
	}
}
